using System;

namespace Welcome
{
	/// <summary>
	/// Summary description for StructExample.
	/// </summary>
	public class StructExample
	{
		public static void Main()
		{
//			Rectangle rectangle = new Rectangle();
//			rectangle.Width = 1;
//			rectangle.Height = 3;

			/*
			 * Esta forma de inicializar no funciona en esta version
			 * 
			Rectangle rectangle = new Rectangle {Width = 1, Height = 3};
			 */

			Rectangle rectangle = new Rectangle(1, 3);

			Console.WriteLine("rectangle: {0}", rectangle);

			Rectangle rectangle2 = new Rectangle(5, 7);
			Console.WriteLine("rectangle2: {0}", rectangle2);

			Rectangle result = rectangle.Add(rectangle2);
			Console.WriteLine("result: {0}", result);

			Console.ReadLine();
		}
	}

	struct Rectangle
	{		
		private int m_width;
		public int Width
		{
			get{return m_width;}
			set{m_width = value;}
		}

		private int m_height;
		public int Height
		{
			get{return m_height;}
			set{m_height = value;}
		}

		public Rectangle(int width, int height)
		{
			m_width = width;
			m_height = height;
		}

		public Rectangle Add(Rectangle rect)
		{
			Rectangle result = new Rectangle(m_width, m_height);
			
			result.Width += rect.Width;
			result.Height += rect.Height;

			return result;
		}

		public override string ToString()
		{
			return m_width.ToString() + ":" + m_height.ToString();
		}
	}
}
